package main

import (
	"fmt"
	"github.com/DeanThompson/ginpprof"
	"github.com/gin-gonic/gin"
	"html/template"
	"mytest/common-admin/route"
	"mytest/util"
	"time"
)

func main() {
	r := gin.Default()
	funcMap := template.FuncMap{
		"date": func() string {
			return time.Now().Format("2006-01-02 15:04:05.00000")
		},
		"md5":                  util.MD5,
		"showValueWithDefault": util.ShowValueWithDefault,
	}

	//r.HTMLRender = ginmultitemplate.LoadTemplateFiles("common-admin/views", ".html", funcMap)
	r.SetFuncMap(funcMap)
	r.LoadHTMLGlob("common-admin/views/**/*")
	r.Static("/static", "common-admin/static")
	//r.StaticFS("/static", http.Dir("common-admin/static"))

	route.LoadAdminRoutes(r)
	ginpprof.Wrap(r)

	err := r.Run(":8080")
	if err != nil {
		panic(fmt.Sprintf("启动失败, err : %s ", err))
	}
}
